import React, { Component } from 'react';
import {
  StyleSheet,
  View,
} from 'react-native';
import PropTypes from 'prop-types';

export default class Divide extends Component {
    static orientations = {
      horizontal: 'horizontal',
      vertical: 'vertical',
    }

    static propTypes = {
      orientation: PropTypes.oneOfType(['horizontal', 'vertical']), // 方向
      width: PropTypes.number, // 宽度
      color: PropTypes.string, // 颜色
    }

    static defaultProps = {
      orientation: 'horizontal',
      width: StyleSheet.hairlineWidth,
      color: '#EFEFF4',
    }

    render() {
      const { style, color, orientation, width } = this.props;
      let targetStyle = style || {};

      if (orientation === 'horizontal') {
        targetStyle = Object.assign(targetStyle, { height: width });
      } else {
        targetStyle = Object.assign(targetStyle, { width });
      }
      targetStyle = Object.assign(targetStyle, { backgroundColor: color });

      return (
        <View style={targetStyle} />
      );
    }
}
